package com.xinqi.xinqidev.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinqi.xinqidev.entity.Hello;
import com.xinqi.xinqidev.entity.dto.HelloDto;
import com.xinqi.xinqidev.entity.enumeration.HelloEnum;
import com.xinqi.xinqidev.mapper.HelloMapper;
import com.xinqi.xinqidev.service.HelloService;
import com.xinqi.xinqidev.pattern.strategy.userservice.HelloStrategyUseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author xin麒
 * @date 2023/10/20 23:49
 */
@Service
public class HelloServiceImpl extends ServiceImpl<HelloMapper, Hello> implements HelloService {
    @Resource
    private HelloMapper helloMapper;

    @Override
    public List<Hello> selectAll() {
        return helloMapper.selectAll();
    }


    @Autowired
    private HelloStrategyUseService helloStrategyUseService;

    @Override
    public String queryByHelloDto(HelloDto helloDto) {
        //假如说处理了很多业务,得到了一个list:
        List<Object> list = Arrays.asList(1, 2, 3, 4);//模拟


        //又处理得到几个参数，例如是2个参数：

        String arg1 = "argument1";
        String arg2 = "argument2";

        int status = helloDto.getStatus();
        HelloEnum anEnum = HelloEnum.getSettleStatusEnumByDataCode(status);
        if (anEnum == null) {
            return "no fount this condition";
        }
        //

        return "" + helloStrategyUseService.processDetail(anEnum, arg1, arg2, list);
    }

    @Override
    public String queryWithOutStrategy(HelloDto helloDto) {
        //假如说处理了很多业务,得到了一个list:
        List<Object> list = Arrays.asList(1, 2, 3, 4);//模拟

        //又处理得到几个参数，例如是2个参数：

        String arg1 = "argument1";
        String arg2 = "argument2";

        int status = helloDto.getStatus();

        String result = "";

        //以上有效参数为arg1, arg2, list

        if (status == 1) {
            //do some things , and get the result by procession with arguments (arg1, arg2, list)
            result = "11";
        } else if (status == 2) {
            //do some things , and get the result by procession with arguments (arg1, arg2, list)
            result = "22";
        } else if (status == 3) {

            //do some things , and get the result by procession with arguments (arg1, arg2, list)
            result = "33";
        } else if (status == 4) {

            //do some things , and get the result by procession with arguments (arg1, arg2, list)
            result = "44";
        }else if (status == 5){
            //。。。。。。。。。。。。
        }
        return result;
    }
}
